<template>
	<view>
		<view class="smart-container">新闻</view>
		<view class="smart-panel-h" @click="goDetailPage('cardViewPage')"><text>置顶新闻页面</text></view>
		<view class="smart-panel-h" @click="goDetailPage('newsPage')"><text>三合一新闻页面</text></view>
		<view class="smart-container">1. 容器</view>
		<view class="smart-panel-h" @click="goDetailPage('view')"><text>view视图</text></view>

		<view class="smart-container">2. 基础内容</view>
		<view class="smart-panel-h" @click="goDetailPage('text')"><text>text文本编辑</text></view>
		<view class="smart-panel-h" @click="goDetailPage('icon')"><text>icon图标</text></view>

		<view class="smart-container">3. 表单组件</view>
		<view class="smart-panel-h" @click="goDetailPage('button')"><text>button按钮</text></view>
		<view class="smart-panel-h" @click="goDetailPage('checkbox')"><text>checkbox多选框</text></view>
		<view class="smart-panel-h" @click="goDetailPage('label')"><text>label标签组件</text></view>
		<view class="smart-panel-h" @click="goDetailPage('input')"><text>input输入框</text></view>
		<view class="smart-panel-h" @click="goDetailPage('textarea')"><text>textarea多行文本输入框</text></view>
		<view class="smart-panel-h" @click="goDetailPage('form')"><text>form表单</text></view>

		<view class="smart-container">4. 导航组件</view>
		<view class="smart-panel-h" @click="goDetailPage('navigator')"><text>navigator</text></view>
		
		<view class="smart-container">5. 多媒体组件</view>
		<view class="smart-panel-h" @click="goDetailPage('image')"><text>image图片组件</text></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		onShow() {
		  console.log("组件页onShow");
		  uni.getStorage({
		    key: 'userName',
		    success(result) {
		      console.log("获取字段成功:", result);
		    },
		    fail(err) {
		      // console.log("获取字段失败: " + JSON.stringify(err));
		    }
		  });
		},
		methods: {
			goDetailPage(e) {
				if (typeof e === 'string') {
					// 单独处理newsPage的路径
					if (e === 'newsPage') {
						uni.navigateTo({
							url: '/pages/NewsTaBar/newsPage/newsPage' // 正确的newsPage路径
						});
					} else {
						// 其他页面保持原有路径规则
						uni.navigateTo({
							url: '/pages/components/' + e + '/' + e
						});
					}
				} else {
					uni.navigateTo({
						url: e.url
					});
				}
			}
		}
	}
</script>

<style>

</style>